home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / edit / thesrc20.zip / comm4.c < prev    next >
C/C++ Source or Header  |  1995-01-26  |  58KB  |  1,937 lines

  1. /***********************************************************************/
  2. /* COMM4.C - Commands P-S                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991-1995 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                     email: M.Hessling@gu.edu.au
  35.  * 36 David Road                     Phone: +61 7 849 7731
  36.  * Holland Park                      Fax:   +61 7 875 5314
  37.  * QLD 4121
  38.  * Australia
  39.  */
  40.  
  41. /*
  42. $Id: comm4.c 2.0 1995/01/26 16:29:59 MH Release MH $
  43. */
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "the.h"
  48. #include "proto.h"
  49.  
  50. #ifdef UNIX
  51. #include <signal.h>
  52. #endif
  53.  
  54. /*#define DEBUG 1*/
  55.  
  56. /*man-start*********************************************************************
  57. COMMAND
  58.      print - send text to default printer or print spooler
  59.  
  60. SYNTAX
  61.      PRint [target] [n]
  62.      PRint LINE [text]
  63.      PRint STRING [text]
  64.      PRint FORMfeed
  65.      PRint CLOSE
  66.  
  67. DESCRIPTION
  68.      The PRINT command writes a portion of the current file to the default
  69.      printer or print spooler, or text entered on the command line.
  70.   
  71.      PRINT [target] [n]
  72.         Sends text from the file contents up to the target to the printer
  73.         followed by a CR/LF (DOS) or LF(UNIX) after each line.
  74.         When [n] is specified, this sends a formfeed after [n] successive
  75.         lines of text.
  76.      PRINT LINE [text]
  77.         Sends the remainder of the text on the command line to the printer
  78.         followed by a CR/LF (DOS) or LF(UNIX).
  79.      PRINT STRING [text]
  80.         Sends the remainder of the text on the command line to the printer
  81.         without any trailing line terminator.
  82.      PRINT FORMFEED
  83.          Sends a formfeed (^L) character to the printer.
  84.      PRINT CLOSE
  85.          Closes the printer spooler.
  86.  
  87. COMPATIBILITY
  88.      XEDIT: N/A
  89.      KEDIT: Compatible.
  90.  
  91. SEE ALSO
  92.      PRINTER
  93.  
  94. STATUS
  95.      Complete.
  96. **man-end**********************************************************************/
  97. #ifdef PROTO
  98. short Print(CHARTYPE *params)
  99. #else
  100. short Print(params)
  101. CHARTYPE *params;
  102. #endif
  103. /***********************************************************************/
  104. {
  105. /*-------------------------- external data ----------------------------*/
  106. /*--------------------------- local data ------------------------------*/
  107. #define PRT_PARAMS  2
  108.  CHARTYPE *word[PRT_PARAMS+1];
  109.  unsigned short num_params=0;
  110.  short page_break=0;
  111.  short rc=RC_OK;
  112.  short target_type=TARGET_NORMAL|TARGET_ALL|TARGET_BLOCK_CURRENT|TARGET_SPARE;
  113.  TARGET target;
  114. #if defined(UNIX)
  115.  CHARTYPE *line_term = (CHARTYPE *)"\n";
  116. #else
  117.  CHARTYPE *line_term = (CHARTYPE *)"\n\r";
  118. #endif
  119. /*--------------------------- processing ------------------------------*/
  120. #ifdef TRACE
  121.  trace_function("comm4.c:   Print");
  122. #endif
  123. /*---------------------------------------------------------------------*/
  124. /* Split parameters up...                                              */
  125. /*---------------------------------------------------------------------*/
  126.  num_params = param_split(params,word,PRT_PARAMS,WORD_DELIMS,TEMP_PARAM);
  127.  if (num_params == 0)
  128.    {
  129.     num_params = 1;
  130.     word[0] = (CHARTYPE *)"1";
  131.    }
  132. /*---------------------------------------------------------------------*/
  133. /* If first argument is LINE...                                        */
  134. /*---------------------------------------------------------------------*/
  135.  if (equal((CHARTYPE *)"line",word[0],4))
  136.    {
  137.     print_line(FALSE,0L,0L,0,(CHARTYPE *)word[1],line_term);
  138. #ifdef TRACE
  139.     trace_return();
  140. #endif
  141.     return(RC_OK);
  142.    }
  143. /*---------------------------------------------------------------------*/
  144. /* If first argument is STRING...                                      */
  145. /*---------------------------------------------------------------------*/
  146.  if (equal((CHARTYPE *)"string",word[0],5))
  147.    {
  148.     print_line(FALSE,0L,0L,0,(CHARTYPE *)word[1],(CHARTYPE *)"");
  149. #ifdef TRACE
  150.     trace_return();
  151. #endif
  152.     return(RC_OK);
  153.    }
  154. /*---------------------------------------------------------------------*/
  155. /* If first argument is FORMFEED...                                    */
  156. /*---------------------------------------------------------------------*/
  157.  if (equal((CHARTYPE *)"formfeed",word[0],4))
  158.    {
  159.     if (num_params > 1)
  160.       {
  161.        display_error(1,word[1],FALSE);
  162. #ifdef TRACE
  163.        trace_return();
  164. #endif
  165.        return(RC_INVALID_OPERAND);
  166.       }
  167.     print_line(FALSE,0L,0L,0,(CHARTYPE *)"",(CHARTYPE *)"\f");
  168. #ifdef TRACE
  169.     trace_return();
  170. #endif
  171.     return(RC_OK);
  172.    }
  173. /*---------------------------------------------------------------------*/
  174. /* If first argument is CLOSE...                                       */
  175. /*---------------------------------------------------------------------*/
  176.  if (equal((CHARTYPE *)"close",word[0],5))
  177.    {
  178.     if (num_params > 1)
  179.       {
  180.        display_error(1,word[1],FALSE);
  181. #ifdef TRACE
  182.        trace_return();
  183. #endif
  184.        return(RC_INVALID_OPERAND);
  185.       }
  186.     print_line(TRUE,0L,0L,0,(CHARTYPE *)"",(CHARTYPE *)"");
  187. #ifdef TRACE
  188.     trace_return();
  189. #endif
  190.     return(RC_OK);
  191.    }
  192. /*---------------------------------------------------------------------*/
  193. /* ...treat all other options as targets...                            */
  194. /*---------------------------------------------------------------------*/
  195.  initialise_target(&target);
  196.  if ((rc = validate_target(params,&target,target_type,get_true_line(),TRUE,TRUE)) != RC_OK)
  197.    {
  198.     free_target(&target);
  199. #ifdef TRACE
  200.     trace_return();
  201. #endif
  202.     return(rc);
  203.    }
  204.  if (target.spare == (-1))
  205.     page_break = 0;
  206.  else
  207.    {
  208.     if (!valid_positive_integer(strtrunc(target.rt[target.spare].string)))
  209.       {
  210.        display_error(4,word[0],FALSE);
  211. #ifdef TRACE
  212.        trace_return();
  213. #endif
  214.        return(RC_INVALID_OPERAND);
  215.       }
  216.     page_break = atoi(strtrunc(target.rt[target.spare].string));
  217.    }
  218.  print_line(FALSE,target.true_line,target.num_lines,page_break,(CHARTYPE *)"",line_term);
  219.  free_target(&target);
  220. #ifdef TRACE
  221.  trace_return();
  222. #endif
  223.  return(RC_OK);
  224. }
  225. /*man-start*********************************************************************
  226. COMMAND
  227.      put - write part of a file to another
  228.  
  229. SYNTAX
  230.      PUT [target] [fileid]
  231.  
  232. DESCRIPTION
  233.      The PUT command writes a portion of the current file to another
  234.      file, either explicit or temporary.
  235.      When no fileid is supplied the temporary file is overwritten.
  236.      When a fileid is supplied the portion of the file written out
  237.      is appended to the specified file.
  238.  
  239. COMPATIBILITY
  240.      XEDIT: Compatible.
  241.      KEDIT: Compatible.
  242.  
  243. SEE ALSO
  244.      PUTD, GET
  245.  
  246. STATUS
  247.      Complete.
  248. **man-end**********************************************************************/
  249. #ifdef PROTO
  250. short Put(CHARTYPE *params)
  251. #else
  252. short Put(params)
  253. CHARTYPE *params;
  254. #endif
  255. /***********************************************************************/
  256. {
  257. /*--------------------------- local data ------------------------------*/
  258.  short rc=RC_OK;
  259. /*--------------------------- processing ------------------------------*/
  260. #ifdef TRACE
  261.  trace_function("comm4.c:   Put");
  262. #endif
  263.  rc = execute_put(params,FALSE);
  264. #ifdef TRACE
  265.  trace_return();
  266. #endif
  267.  return(rc);
  268. }
  269. /*man-start*********************************************************************
  270. COMMAND
  271.      putd - write part of a file to another and delete
  272.  
  273. SYNTAX
  274.      PUTD [target] [fileid]
  275.  
  276. DESCRIPTION
  277.      The PUTD command writes a portion of the current file to another
  278.      file, either explicit or temporary and deletes those lines written.
  279.      When no fileid is supplied the temporary file is overwritten.
  280.      When a fileid is supplied the portion of the file written out
  281.      is appended to the specified file.
  282.  
  283. COMPATIBILITY
  284.      XEDIT: Compatible.
  285.      KEDIT: Compatible.
  286.  
  287. SEE ALSO
  288.      PUT, GET
  289.  
  290. STATUS
  291.      Complete.
  292. **man-end**********************************************************************/
  293. #ifdef PROTO
  294. short Putd(CHARTYPE *params)
  295. #else
  296. short Putd(params)
  297. CHARTYPE *params;
  298. #endif
  299. /***********************************************************************/
  300. {
  301. /*--------------------------- local data ------------------------------*/
  302.  short rc=RC_OK;
  303. /*--------------------------- processing ------------------------------*/
  304. #ifdef TRACE
  305.  trace_function("comm4.c:   Putd");
  306. #endif
  307.  rc = execute_put(params,TRUE);
  308. #ifdef TRACE
  309.  trace_return();
  310. #endif
  311.  return(rc);
  312. }
  313. /*man-start*********************************************************************
  314. COMMAND
  315.      qquit - exit from the current file without saving changes
  316.  
  317. SYNTAX
  318.      QQuit
  319.  
  320. DESCRIPTION
  321.      The QQUIT command exits the user from the current file, whether
  322.      changes have been made to the file or not.
  323.      The previous file in the ring then becomes the current file.
  324.      If the current file is the only file in the ring, the user is
  325.      returned to the Operating System.
  326.  
  327. COMPATIBILITY
  328.      XEDIT: N/A
  329.      KEDIT: Compatible.
  330.  
  331. SEE ALSO
  332.      QUIT
  333.  
  334. STATUS
  335.      Complete
  336. **man-end**********************************************************************/
  337. #ifdef PROTO
  338. short Qquit(CHARTYPE *params)
  339. #else
  340. short Qquit(params)
  341. CHARTYPE *params;
  342. #endif
  343. /***********************************************************************/
  344. {
  345. /*-------------------------- external data ----------------------------*/
  346. /*--------------------------- local data ------------------------------*/
  347. /*--------------------------- processing ------------------------------*/
  348. #ifdef TRACE
  349.  trace_function("comm4.c:   Qquit");
  350. #endif
  351. /*---------------------------------------------------------------------*/
  352. /* No arguments are allowed; error if any are present.                 */
  353. /*---------------------------------------------------------------------*/
  354.  if (strcmp(params,"") != 0)
  355.    {
  356.     display_error(1,(CHARTYPE *)params,FALSE);
  357. #ifdef TRACE
  358.     trace_return();
  359. #endif
  360.     return(RC_INVALID_OPERAND);
  361.    }
  362.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  363.  free_view_memory();
  364. #ifdef TRACE
  365.  trace_return();
  366. #endif
  367.  return(RC_OK);
  368. }
  369. /*man-start*********************************************************************
  370. COMMAND
  371.      query - display various option settings
  372.  
  373. SYNTAX
  374.      Query item
  375.  
  376. DESCRIPTION
  377.      The QUERY command displays the various settings for options set
  378.      by THE.
  379.  
  380. COMPATIBILITY
  381.      XEDIT: Compatible functionality, but not all options.
  382.      KEDIT: Compatible functionality, but not all options.
  383.  
  384. SEE ALSO
  385.      STATUS, MODIFY
  386.  
  387. STATUS
  388.      Complete.
  389. **man-end**********************************************************************/
  390. #ifdef PROTO
  391. short Query(CHARTYPE *params)
  392. #else
  393. short Query(params)
  394. CHARTYPE *params;
  395. #endif
  396. /***********************************************************************/
  397. {
  398. /*-------------------------- external data ----------------------------*/
  399.  extern VALUE item_values[18];
  400.  extern CHARTYPE *temp_cmd;
  401. /*--------------------------- local data ------------------------------*/
  402.  register short i=0;
  403.  short itemno=0;
  404. /*--------------------------- processing ------------------------------*/
  405. #ifdef TRACE
  406.  trace_function("comm4.c:   Query");
  407. #endif
  408.  if ((itemno = find_item(params,QUERY_QUERY)) == (-1))
  409.     {
  410.      display_error(1,params,FALSE);
  411. #ifdef TRACE
  412.      trace_return();
  413. #endif
  414.      return(RC_INVALID_OPERAND);
  415.     }
  416.  
  417.  itemno = get_item_values(itemno,(CHARTYPE *)"",QUERY_QUERY,0L,NULL,0L);
  418.  strcpy(temp_cmd,"");
  419.  for (i=0;i<itemno+1;i++)
  420.    {
  421.     strcat(temp_cmd,item_values[i].value);
  422.     strcat(temp_cmd," ");
  423.    }
  424.  display_error(0,temp_cmd,TRUE);
  425. #ifdef TRACE
  426.  trace_return();
  427. #endif
  428.  return(RC_OK);
  429. }
  430. /*man-start*********************************************************************
  431. COMMAND
  432.      quit - exit from the current file if no changes made
  433.  
  434. SYNTAX
  435.      QUIT
  436.  
  437. DESCRIPTION
  438.      The QUIT command exits the user from the current file, provided
  439.      no changes have been made to the file. An error message will be
  440.      displayed if changes have been made.
  441.      The previous file in the ring then becomes the current file.
  442.      If the current file is the only file in the ring, the user is
  443.      returned to the Operating System.
  444.  
  445. COMPATIBILITY
  446.      XEDIT: Does not support return code option.
  447.      KEDIT: Compatible.
  448.  
  449. SEE ALSO
  450.      QQUIT
  451.  
  452. STATUS
  453.      Complete
  454. **man-end**********************************************************************/
  455. #ifdef PROTO
  456. short Quit(CHARTYPE *params)
  457. #else
  458. short Quit(params)
  459. CHARTYPE *params;
  460. #endif
  461. /***********************************************************************/
  462. {
  463. /*-------------------------- external data ----------------------------*/
  464. /*--------------------------- local data ------------------------------*/
  465. /*--------------------------- processing ------------------------------*/
  466. #ifdef TRACE
  467.  trace_function("comm4.c:   Quit");
  468. #endif
  469. /*---------------------------------------------------------------------*/
  470. /* No arguments are allowed; error if any are present.                 */
  471. /*---------------------------------------------------------------------*/
  472.  if (strcmp(params,"") != 0)
  473.    {
  474.     display_error(1,(CHARTYPE *)params,FALSE);
  475. #ifdef TRACE
  476.     trace_return();
  477. #endif
  478.     return(RC_INVALID_OPERAND);
  479.    }
  480.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  481.  if (CURRENT_FILE->save_alt > 0)
  482.    {
  483.     display_error(22,(CHARTYPE *)"",FALSE);
  484. #ifdef TRACE
  485.     trace_return();
  486. #endif
  487.     return(RC_FILE_CHANGED);
  488.    }
  489.  free_view_memory();
  490. #ifdef TRACE
  491.  trace_return();
  492. #endif
  493.  return(RC_OK);
  494. }
  495. /*man-start*********************************************************************
  496. COMMAND
  497.      readv - read keystrokes and pass to macro
  498.  
  499. SYNTAX
  500.      READV Cmdline|KEY
  501.  
  502. DESCRIPTION
  503.      The READV command allows a REXX macro to interact with the user 
  504.      by accepting keystrokes.
  505.  
  506.      The macro obtains the entered information by setting REXX
  507.      variables. These are set as follows:
  508.  
  509.      For READV KEY
  510.  
  511.          readv.0 = 3
  512.          readv.1 = name of key (empty if unknown)
  513.          readv.2 = ASCII value of key (null if not an ASCII code)
  514.          readv.3 = curses key value (or ASCII code if an ASCII code)
  515.  
  516.      For READV CMDLINE
  517.  
  518.          readv.0 = 1
  519.          readv.1 = contents of command line
  520.  
  521. COMPATIBILITY
  522.      XEDIT: Similar to READ CMDLINE option.
  523.      KEDIT: Compatible.
  524.  
  525. STATUS
  526.      Incomplete. CMDLINE option not implemented.
  527. **man-end**********************************************************************/
  528. #ifdef PROTO
  529. short Readv(CHARTYPE *params)
  530. #else
  531. short Readv(params)
  532. CHARTYPE *params;
  533. #endif
  534. /***********************************************************************/
  535. {
  536. /*-------------------------- external data ----------------------------*/
  537.  extern bool in_macro;
  538.  extern bool rexx_support;
  539. /*--------------------------- local data ------------------------------*/
  540.  short rc=RC_OK,itemno=0,num_values=0;
  541. /*--------------------------- processing ------------------------------*/
  542. #ifdef TRACE
  543.  trace_function("comm4.c:   Readv");
  544.  if (!in_macro)
  545.    {
  546.     display_error(53,(CHARTYPE *)"",FALSE);
  547. #ifdef TRACE
  548.     trace_return();
  549. #endif
  550.     return(RC_INVALID_ENVIRON);
  551.    }
  552. #endif
  553.  
  554.  if (rexx_support)
  555.    {
  556.     if (equal((CHARTYPE *)"key",params,3))
  557.       {
  558. /*---------------------------------------------------------------------*/
  559. /* Find the item in the list of valid extract options...               */
  560. /*---------------------------------------------------------------------*/
  561.        if ((itemno = find_item("READV",QUERY_READV)) == (-1))
  562.          {
  563.           display_error(1,params,FALSE);
  564. #ifdef TRACE
  565.           trace_return();
  566. #endif
  567.           return(RC_INVALID_OPERAND);
  568.          }
  569. /*---------------------------------------------------------------------*/
  570. /* Get the current settings for the valid item...                      */
  571. /*---------------------------------------------------------------------*/
  572.        num_values = get_item_values(itemno,NULL,QUERY_READV,0L,NULL,0L);
  573. /*---------------------------------------------------------------------*/
  574. /* If the arguments to the item are invalid, return with an error.     */
  575. /*---------------------------------------------------------------------*/
  576.        if (num_values == EXTRACT_ARG_ERROR)
  577.          {
  578. #ifdef TRACE
  579.           trace_return();
  580. #endif
  581.           return(RC_INVALID_OPERAND);
  582.          }
  583. /*---------------------------------------------------------------------*/
  584. /* If the REXX variables have already been set, don't try to set them. */
  585. /*---------------------------------------------------------------------*/
  586.        if (num_values != EXTRACT_VARIABLES_SET)
  587.           rc = set_extract_variables(itemno);
  588.       }
  589.     else
  590.       {
  591.        if (equal((CHARTYPE *)"cmdline",params,1))
  592.          {
  593.          }
  594.        else
  595.          {
  596.           display_error(1,params,FALSE);
  597. #ifdef TRACE
  598.           trace_return();
  599. #endif
  600.           return(RC_INVALID_OPERAND);
  601.          }
  602.       }
  603.    }
  604.  else
  605.    {
  606.     display_error(53,(CHARTYPE *)"",FALSE);
  607. #ifdef TRACE
  608.     trace_return();
  609. #endif
  610.     return(RC_INVALID_ENVIRON);
  611.    }
  612. #ifdef TRACE
  613.  trace_return();
  614. #endif
  615.  return(rc);
  616. }
  617. /*man-start*********************************************************************
  618. COMMAND
  619.      recover - recover changed or deleted lines
  620.  
  621. SYNTAX
  622.      RECover [n|*]
  623.  
  624. DESCRIPTION
  625.      The RECOVER command restores the last n changed or deleted lines
  626.      back into the body of the file.
  627.  
  628. COMPATIBILITY
  629.      XEDIT: Also recovers changes to lines, not just lines deleted.
  630.      KEDIT: Compatible.
  631.  
  632. STATUS
  633.      Complete.
  634. **man-end**********************************************************************/
  635. #ifdef PROTO
  636. short Recover(CHARTYPE *params)
  637. #else
  638. short Recover(params)
  639. CHARTYPE *params;
  640. #endif
  641. /***********************************************************************/
  642. {
  643. /*-------------------------- external data ----------------------------*/
  644. /*--------------------------- local data ------------------------------*/
  645. #define REC_PARAMS  1
  646.  CHARTYPE *word[REC_PARAMS+1];
  647.  unsigned short num_params=0;
  648.  short num=0;
  649. /*--------------------------- processing ------------------------------*/
  650. #ifdef TRACE
  651.  trace_function("comm4.c:   Recover");
  652. #endif
  653. /*---------------------------------------------------------------------*/
  654. /* Validate the parameters that have been supplied. The one and only   */
  655. /* parameter should be a positive integer greater than zero or '*'.    */
  656. /* If no parameter is supplied, 1 is assumed.                          */
  657. /*---------------------------------------------------------------------*/
  658.  num_params = param_split(params,word,REC_PARAMS,WORD_DELIMS,TEMP_PARAM);
  659.  if (num_params == 0)
  660.     {
  661.      num_params = 1;
  662.      word[0] = (CHARTYPE *)"1";
  663.     }
  664.  if (num_params != 1)
  665.     {
  666.      display_error(1,word[1],FALSE);
  667. #ifdef TRACE
  668.      trace_return();
  669. #endif
  670.      return(RC_INVALID_OPERAND);
  671.     }
  672.  if (strcmp(word[0],"*") == 0)
  673.    {
  674.     num = 99;
  675.    }
  676.  else
  677.    {
  678.     if (!valid_positive_integer(word[0]))
  679.        {
  680.         display_error(4,word[0],FALSE);
  681. #ifdef TRACE
  682.         trace_return();
  683. #endif
  684.         return(RC_INVALID_OPERAND);
  685.        }
  686.     num = atoi(word[0]);
  687.    }
  688.  
  689.  get_from_recovery_list(num);
  690.  
  691. #ifdef TRACE
  692.  trace_return();
  693. #endif
  694.  return(RC_OK);
  695. }
  696. /*man-start*********************************************************************
  697. COMMAND
  698.      redraw - redraw the current screen
  699.  
  700. SYNTAX
  701.      REDRAW
  702.  
  703. DESCRIPTION
  704.      The REDRAW command redraws the current contents of the screen.
  705.      This is usually used when some outside influence has affected 
  706.      the display.
  707.  
  708. COMPATIBILITY
  709.      XEDIT: N/A
  710.      KEDIT: N/A
  711.  
  712. SEE ALSO
  713.      REFRESH
  714.  
  715. STATUS
  716.      Complete.
  717. **man-end**********************************************************************/
  718. #ifdef PROTO
  719. short Redraw(CHARTYPE *params)
  720. #else
  721. short Redraw(params)
  722. CHARTYPE *params;
  723. #endif
  724. /***********************************************************************/
  725. {
  726. /*-------------------------- external data ----------------------------*/
  727. /*--------------------------- local data ------------------------------*/
  728. /*--------------------------- processing ------------------------------*/
  729. #ifdef TRACE
  730.  trace_function("comm4.c:   Redraw");
  731. #endif
  732.  if (strcmp(params,"") != 0)
  733.    {
  734.     display_error(1,params,FALSE);
  735. #ifdef TRACE
  736.     trace_return();
  737. #endif
  738.     return(RC_INVALID_OPERAND);
  739.    }
  740.  restore_THE();
  741. #ifdef TRACE
  742.  trace_return();
  743. #endif
  744.  return(RC_OK);
  745. }
  746. /*man-start*********************************************************************
  747. COMMAND
  748.      refresh - refresh the contents of the current screen
  749.  
  750. SYNTAX
  751.      REFRESH
  752.  
  753. DESCRIPTION
  754.      The REFRESH command refreshes what is being displayed on the screen.
  755.      This is usually used from within a macro to indicate the progress
  756.      of the macro.
  757.  
  758. COMPATIBILITY
  759.      XEDIT: Compatible.
  760.      KEDIT: Compatible.
  761.  
  762. SEE ALSO
  763.      REDRAW
  764.  
  765. STATUS
  766.      Complete.
  767. **man-end**********************************************************************/
  768. #ifdef PROTO
  769. short THERefresh(CHARTYPE *params)
  770. #else
  771. short THERefresh(params)
  772. CHARTYPE *params;
  773. #endif
  774. /***********************************************************************/
  775. {
  776. /*-------------------------- external data ----------------------------*/
  777.  extern bool in_macro;
  778.  extern CHARTYPE display_screens;
  779. /*--------------------------- local data ------------------------------*/
  780.  bool save_in_macro=in_macro;
  781. /*--------------------------- processing ------------------------------*/
  782. #ifdef TRACE
  783.  trace_function("comm4.c:   THERefresh");
  784. #endif
  785.  if (strcmp(params,"") != 0)
  786.    {
  787.     display_error(1,params,FALSE);
  788. #ifdef TRACE
  789.     trace_return();
  790. #endif
  791.     return(RC_INVALID_OPERAND);
  792.    }
  793.  in_macro = FALSE;
  794.  if (display_screens > 1)
  795.    {
  796.     build_other_screen();
  797.     display_other_screen();
  798.    }
  799.  build_current_screen(); 
  800.  display_current_screen();
  801.  doupdate();
  802.  in_macro = save_in_macro;
  803. #ifdef TRACE
  804.  trace_return();
  805. #endif
  806.  return(RC_OK);
  807. }
  808. /*man-start*********************************************************************
  809. COMMAND
  810.      repeat - repeat the last command
  811.  
  812. SYNTAX
  813.      REPEat [target]
  814.  
  815. DESCRIPTION
  816.      The REPEAT command advances the current line and executes the
  817.      last command. It is equivalent to NEXT 1 (or UP 1) and = for
  818.      the specified number of times.
  819.  
  820. COMPATIBILITY
  821.      XEDIT: Compatible.
  822.      KEDIT: Compatible.
  823.  
  824. STATUS
  825.      Incomplete
  826. **man-end**********************************************************************/
  827. #ifdef PROTO
  828. short Repeat(CHARTYPE *params)
  829. #else
  830. short Repeat(params)
  831. CHARTYPE *params;
  832. #endif
  833. /***********************************************************************/
  834. {
  835. /*-------------------------- external data ----------------------------*/
  836. /*--------------------------- local data ------------------------------*/
  837.  short len_params=0,rc=RC_OK;
  838.  LINETYPE true_line=0L;
  839.  LINE *curr=NULL;
  840.  SELECTTYPE current_select=0;
  841. /*--------------------------- processing ------------------------------*/
  842. #ifdef TRACE
  843.  trace_function("comm4.c:   Repeat");
  844. #endif
  845.  
  846.  display_error(0,(CHARTYPE *)"This command has yet to be implemented",FALSE);
  847. #ifdef TRACE
  848.  trace_return();
  849. #endif
  850.  return(RC_OK);
  851. }
  852. /*man-start*********************************************************************
  853. COMMAND
  854.      replace - replace the current line with supplied text
  855.  
  856. SYNTAX
  857.      Replace [text]
  858.  
  859. DESCRIPTION
  860.      The REPLACE command replaces the current line with the supplied
  861.      text.
  862.  
  863. COMPATIBILITY
  864.      XEDIT: Compatible.
  865.      KEDIT: Compatible.
  866.  
  867. STATUS
  868.      Complete.
  869. **man-end**********************************************************************/
  870. #ifdef PROTO
  871. short Replace(CHARTYPE *params)
  872. #else
  873. short Replace(params)
  874. CHARTYPE *params;
  875. #endif
  876. /***********************************************************************/
  877. {
  878. /*-------------------------- external data ----------------------------*/
  879. /*--------------------------- local data ------------------------------*/
  880.  short len_params=0,rc=RC_OK;
  881.  LINETYPE true_line=0L;
  882.  LINE *curr=NULL;
  883.  SELECTTYPE current_select=0;
  884. /*--------------------------- processing ------------------------------*/
  885. #ifdef TRACE
  886.  trace_function("comm4.c:   Replace");
  887. #endif
  888.  
  889.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  890.  if (CURRENT_VIEW->hex)
  891.    {
  892.     if ((len_params = convert_hex_strings(params)) == (-1))
  893.       {
  894.        display_error(32,(CHARTYPE *)"",FALSE);
  895. #ifdef TRACE
  896.        trace_return();
  897. #endif
  898.        return(RC_INVALID_OPERAND);
  899.       }
  900.    }
  901.  else
  902.    len_params = strlen(params);
  903.  true_line = get_true_line();
  904.  if (TOF(true_line)
  905.  ||  BOF(true_line))
  906.    {
  907.     display_error(38,(CHARTYPE *)"",FALSE);
  908. #ifdef TRACE
  909.     trace_return();
  910. #endif
  911.     return(RC_OUT_OF_MEMORY); /* ?? */
  912.    }
  913.  curr = lll_find(CURRENT_FILE->first_line,true_line);
  914.  current_select = curr->select;
  915.  add_to_recovery_list(curr->line,curr->length);
  916.  curr = delete_line(CURRENT_FILE->first_line,curr,DIRECTION_FORWARD);
  917.  curr = curr->prev;
  918.  if ((curr = add_line(CURRENT_FILE->first_line,curr,
  919.                           params,len_params,current_select)) == NULL)
  920.    {
  921.     display_error(30,(CHARTYPE *)"",FALSE);
  922. #ifdef TRACE
  923.     trace_return();
  924. #endif
  925.     return(RC_OUT_OF_MEMORY);
  926.    }
  927.  if ((rc = increment_alt(CURRENT_FILE)) != RC_OK)
  928.    {
  929. #ifdef TRACE
  930.     trace_return();
  931. #endif
  932.     return(rc);
  933.    }
  934.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  935.  
  936.  build_current_screen(); 
  937.  display_current_screen();
  938.  
  939. #ifdef TRACE
  940.  trace_return();
  941. #endif
  942.  return(RC_OK);
  943. }
  944. /*man-start*********************************************************************
  945. COMMAND
  946.      reset - cancel the marked block or prefix commands or both
  947.  
  948. SYNTAX
  949.      RESet ALL|Block|Prefix
  950.  
  951. DESCRIPTION
  952.      The RESET command unmarks any marked block or outstanding prefix
  953.      commands or both.
  954.  
  955. COMPATIBILITY
  956.      XEDIT: Adds Block and All options.
  957.      KEDIT: Compatible.
  958.  
  959. STATUS
  960.      Complete.
  961. **man-end**********************************************************************/
  962. #ifdef PROTO
  963. short Reset(CHARTYPE *params)
  964. #else
  965. short Reset(params)
  966. CHARTYPE *params;
  967. #endif
  968. /***********************************************************************/
  969. {
  970. /*------------------------- external data -----------------------------*/
  971.  extern VIEW_DETAILS *vd_mark;
  972.  extern CHARTYPE *pre_rec;
  973.  extern unsigned short pre_rec_len;
  974. /*--------------------------- local data ------------------------------*/
  975. #define RES_PARAMS  1
  976.  CHARTYPE *word[RES_PARAMS+1];
  977.  unsigned short num_params=0;
  978.  PPC *curr_ppc=NULL;
  979. /*--------------------------- processing ------------------------------*/
  980. #ifdef TRACE
  981.  trace_function("comm4.c:   Reset");
  982. #endif
  983.  num_params = param_split(params,word,RES_PARAMS,WORD_DELIMS,TEMP_PARAM);
  984.  if (num_params > 1)
  985.    {
  986.     display_error(1,word[1],FALSE);
  987. #ifdef TRACE
  988.     trace_return();
  989. #endif
  990.     return(RC_INVALID_OPERAND);
  991.    }
  992. /*---------------------------------------------------------------------*/
  993. /* Reset the marked block, if any.                                     */
  994. /*---------------------------------------------------------------------*/
  995.  if (equal((CHARTYPE *)"block",word[0],1)
  996.  ||  equal((CHARTYPE *)"all",word[0],3)
  997.  ||  num_params == 0)
  998.    {
  999.     if (MARK_VIEW != (VIEW_DETAILS *)NULL)
  1000.       {
  1001.        MARK_VIEW->marked_line = MARK_VIEW->marked_col = FALSE;
  1002.        MARK_VIEW = (VIEW_DETAILS *)NULL;
  1003.        build_current_screen(); 
  1004.        display_current_screen();
  1005.       }
  1006.    }
  1007. /*---------------------------------------------------------------------*/
  1008. /* Reset the pending prefix commands, if any.                          */
  1009. /*---------------------------------------------------------------------*/
  1010.  if (equal((CHARTYPE *)"prefix",word[0],1)
  1011.  ||  equal((CHARTYPE *)"all",word[0],3)
  1012.  ||  num_params == 0)
  1013.    {
  1014.     curr_ppc = CURRENT_FILE->first_ppc;
  1015.     while(curr_ppc != NULL)
  1016.        curr_ppc = delete_pending_prefix_command(curr_ppc,CURRENT_FILE,(LINE *)NULL);
  1017.     memset(pre_rec,' ',PREFIX_WIDTH+1);
  1018.     pre_rec_len = 0;
  1019.     build_current_screen(); 
  1020.     display_current_screen();
  1021.    }
  1022. #ifdef TRACE
  1023.  trace_return();
  1024. #endif
  1025.  return(RC_OK);
  1026. }
  1027. /*man-start*********************************************************************
  1028. COMMAND
  1029.      rgtleft - scroll the screen to the left or right
  1030.  
  1031. SYNTAX
  1032.      RGTLEFT [n]
  1033.  
  1034. DESCRIPTION
  1035.      The RGTLEFT command scrolls the screen n columns to the right
  1036.      if the value of VERSHIFT is less than or equal to 0, or if
  1037.      the value of VERSHIFT is greater than 0, the screen is
  1038.      scrolled n columns to the left.
  1039.      If n is not specified, the screen scrolls by three quarters the
  1040.      number of columns displayed.
  1041.  
  1042. COMPATIBILITY
  1043.      XEDIT: Compatible.
  1044.      KEDIT: Compatible.
  1045.  
  1046. SEE ALSO
  1047.      LEFT, RIGHT
  1048.  
  1049. STATUS
  1050.      Complete.
  1051. **man-end**********************************************************************/
  1052. #ifdef PROTO
  1053. short Rgtleft(CHARTYPE *params)
  1054. #else
  1055. short Rgtleft(params)
  1056. CHARTYPE *params;
  1057. #endif
  1058. /***********************************************************************/
  1059. {
  1060. /*-------------------------- external data ----------------------------*/
  1061. /*--------------------------- local data ------------------------------*/
  1062.  short rc=RC_OK;
  1063.  LINETYPE shift_val=0L;
  1064. /*--------------------------- processing ------------------------------*/
  1065. #ifdef TRACE
  1066.  trace_function("comm3.c:   Rgtleft");
  1067. #endif
  1068. /*---------------------------------------------------------------------*/
  1069. /* Validate only parameter, a positive integer. 3/4 if no argument.    */
  1070. /*---------------------------------------------------------------------*/
  1071.  if (blank_field(params))
  1072.     shift_val = min(CURRENT_SCREEN.cols[WINDOW_MAIN],
  1073.                   1 + CURRENT_VIEW->verify_end - CURRENT_VIEW->verify_start)*3/4;
  1074.  else
  1075.    {
  1076.     if (valid_positive_integer(params))
  1077.        shift_val = atol(params);
  1078.    }
  1079.  if (shift_val == (-1))                            /* invalid argument */
  1080.    {
  1081.     display_error(1,params,FALSE);
  1082. #ifdef TRACE
  1083.     trace_return();
  1084. #endif
  1085.     return(RC_INVALID_OPERAND);
  1086.    }
  1087.  if ((LINETYPE)CURRENT_VIEW->verify_col - (LINETYPE)CURRENT_VIEW->verify_start > 0)
  1088.     shift_val = -shift_val;
  1089.  CURRENT_VIEW->verify_col = max(1,CURRENT_VIEW->verify_col+shift_val);
  1090.  build_current_screen();
  1091.  display_current_screen();
  1092. #ifdef TRACE
  1093.  trace_return();
  1094. #endif
  1095.  return(rc);
  1096. }
  1097. /*man-start*********************************************************************
  1098. COMMAND
  1099.      right - scroll the screen to the right
  1100.  
  1101. SYNTAX
  1102.      RIght [n|HALF]
  1103.  
  1104. DESCRIPTION
  1105.      The RIGHT command scrolls the screen n columns to the right.
  1106.      If no parameter is supplied, the screen is scrolled by 1
  1107.      column. If HALF is specified the screen is scrolled by half 
  1108.      the number of columns in the FILEAREA.
  1109.  
  1110. COMPATIBILITY
  1111.      XEDIT: Compatible.
  1112.      KEDIT: Compatible.
  1113.  
  1114. SEE ALSO
  1115.      LEFT, RGTLEFT
  1116.  
  1117. STATUS
  1118.      Complete.
  1119. **man-end**********************************************************************/
  1120. #ifdef PROTO
  1121. short Right(CHARTYPE *params)
  1122. #else
  1123. short Right(params)
  1124. CHARTYPE *params;
  1125. #endif
  1126. /***********************************************************************/
  1127. {
  1128. /*-------------------------- external data ----------------------------*/
  1129. /*--------------------------- local data ------------------------------*/
  1130.  short rc=RC_OK;
  1131.  LINETYPE shift_val=-1L;
  1132. /*--------------------------- processing ------------------------------*/
  1133. #ifdef TRACE
  1134.  trace_function("comm3.c:   Right");
  1135. #endif
  1136. /*---------------------------------------------------------------------*/
  1137. /* Validate only parameter, HALF or positive integer. 1 if no argument.*/
  1138. /*---------------------------------------------------------------------*/
  1139.  if (equal(params,(CHARTYPE *)"half",4))
  1140.     shift_val = CURRENT_SCREEN.cols[WINDOW_MAIN]/2;
  1141.  if (blank_field(params))
  1142.     shift_val = 1L;
  1143.  if (shift_val == (-1))              /* argument not HALF or empty ... */
  1144.    {
  1145.     if (valid_positive_integer(params))
  1146.       {
  1147.        shift_val = atol(params);
  1148.        if (shift_val != 0)
  1149.           shift_val = shift_val;
  1150.       }
  1151.    }
  1152.  if (shift_val == (-1))                            /* invalid argument */
  1153.    {
  1154.     display_error(1,params,FALSE);
  1155. #ifdef TRACE
  1156.     trace_return();
  1157. #endif
  1158.     return(RC_INVALID_OPERAND);
  1159.    }
  1160. /*---------------------------------------------------------------------*/
  1161. /* If the argument is 0, restore the original verify columns display.  */
  1162. /*---------------------------------------------------------------------*/
  1163.  if (shift_val == 0L)
  1164.     CURRENT_VIEW->verify_col = CURRENT_VIEW->verify_start;
  1165.  else
  1166.     CURRENT_VIEW->verify_col = max(1,CURRENT_VIEW->verify_col+shift_val);
  1167.  build_current_screen();
  1168.  display_current_screen();
  1169. #ifdef TRACE
  1170.  trace_return();
  1171. #endif
  1172.  return(rc);
  1173. }
  1174. /*man-start*********************************************************************
  1175. COMMAND
  1176.      save - save changes to current file
  1177.  
  1178. SYNTAX
  1179.      SAVE [fileid]
  1180.  
  1181. DESCRIPTION
  1182.      The SAVE command writes the current file to disk. If a fileid is
  1183.      supplied, the current file is saved in that file, unless the file
  1184.      already exists which will result in an error message being
  1185.      displayed. The 'Alterations' counter on the heading line is 
  1186.      reset to zero.
  1187.  
  1188. COMPATIBILITY
  1189.      XEDIT: Compatible.
  1190.      KEDIT: Compatible.
  1191.  
  1192. SEE ALSO
  1193.      SSAVE, FILE, FFILE
  1194.  
  1195. STATUS
  1196.      Complete
  1197. **man-end**********************************************************************/
  1198. #ifdef PROTO
  1199. short Save(CHARTYPE *params)
  1200. #else
  1201. short Save(params)
  1202. CHARTYPE *params;
  1203. #endif
  1204. /***********************************************************************/
  1205. {
  1206. /*-------------------------- external data ----------------------------*/
  1207. /*--------------------------- local data ------------------------------*/
  1208.  short rc=RC_OK;
  1209. /*--------------------------- processing ------------------------------*/
  1210. #ifdef TRACE
  1211.  trace_function("comm4.c:   Save");
  1212. #endif
  1213.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  1214.  if ((rc = save_file(CURRENT_FILE,params,FALSE,CURRENT_FILE->number_lines,1L,FALSE,0,max_line_length,TRUE)) != RC_OK)
  1215.    {
  1216. #ifdef TRACE
  1217.     trace_return();
  1218. #endif
  1219.     return(rc);
  1220.    }
  1221. /*---------------------------------------------------------------------*/
  1222. /* Only set the alteration count to zero if save was successful.       */
  1223. /*---------------------------------------------------------------------*/
  1224.  CURRENT_FILE->autosave_alt = CURRENT_FILE->save_alt = 0;
  1225. /*---------------------------------------------------------------------*/
  1226. /* If autosave is on at the time of Saving, remove the .aus file...    */
  1227. /*---------------------------------------------------------------------*/
  1228.  if (CURRENT_FILE->autosave > 0)
  1229.     rc = remove_aus_file(CURRENT_FILE);
  1230. #ifdef TRACE
  1231.  trace_return();
  1232. #endif
  1233.  return(rc);
  1234. }
  1235. /*man-start*********************************************************************
  1236. COMMAND
  1237.      schange - selectively change strings
  1238.  
  1239. SYNTAX
  1240.      SCHange /string1/string2/ [target] [n] [m]
  1241.  
  1242. DESCRIPTION
  1243.      The SCHANGE command changes one string of text to another.
  1244.  
  1245.      The first parameter to the change command is the old and new
  1246.      string values, seperated by delimiters.
  1247.      The allowable delimiters are '/' '\' and '@'.
  1248.  
  1249.      The second parameter is the target; how many lines are to be
  1250.      searched for occurrences of the first string to be changed.
  1251.  
  1252.      The third parameter determines how many occurrences of 'string1'
  1253.      are to be changed on each line.
  1254.  
  1255.      The fourth parameter determines at which occurrences of 'string1'
  1256.      on the line are changes to commence.
  1257.  
  1258. COMPATIBILITY
  1259.      XEDIT: Functionally compatible, but syntax different.
  1260.      KEDIT: Compatible.
  1261.  
  1262. DEFAULT
  1263.      1 1 1
  1264.  
  1265. SEE ALSO
  1266.      CHANGE
  1267.  
  1268. STATUS
  1269.      Complete.
  1270. **man-end**********************************************************************/
  1271. #ifdef PROTO
  1272. short Schange(CHARTYPE *params)
  1273. #else
  1274. short Schange(params)
  1275. CHARTYPE *params;
  1276. #endif
  1277. /***********************************************************************/
  1278. {
  1279. /*--------------------------- local data ------------------------------*/
  1280.  short rc=RC_OK;
  1281. /*--------------------------- processing ------------------------------*/
  1282. #ifdef TRACE
  1283.  trace_function("comm4.c:   Schange");
  1284. #endif
  1285.  rc = execute_change_command(params,TRUE);
  1286. #ifdef TRACE
  1287.  trace_return();
  1288. #endif
  1289.  return(rc);
  1290. }
  1291. /*man-start*********************************************************************
  1292. COMMAND
  1293.      set - execute various set commands
  1294.  
  1295. SYNTAX
  1296.      SET set_command [set_command parameter(s) ...]
  1297.  
  1298. DESCRIPTION
  1299.      The SET command is a front end to existing 'set' commands. It treats
  1300.      the first parameter it receives as a command and executes it.
  1301.  
  1302. COMPATIBILITY
  1303.      XEDIT: Compatible.
  1304.      KEDIT: Compatible.
  1305.  
  1306. STATUS
  1307.      Complete.
  1308. **man-end**********************************************************************/
  1309. #ifdef PROTO
  1310. short Set(CHARTYPE *params)
  1311. #else
  1312. short Set(params)
  1313. CHARTYPE *params;
  1314. #endif
  1315. /***********************************************************************/
  1316. {
  1317. /*--------------------------- local data ------------------------------*/
  1318.  short rc=RC_OK;
  1319. /*--------------------------- processing ------------------------------*/
  1320. #ifdef TRACE
  1321.  trace_function("comm4.c:   Set");
  1322. #endif
  1323.  rc = execute_set_sos_command(TRUE,params);
  1324. #ifdef TRACE
  1325.  trace_return();
  1326. #endif
  1327.  return(rc);
  1328. }
  1329. /*man-start*********************************************************************
  1330. COMMAND
  1331.      shift - move text left or right
  1332.  
  1333. SYNTAX
  1334.      SHift Left|Right [n] [target]
  1335.  
  1336. DESCRIPTION
  1337.      The SHIFT command moves text in the direction specified the number
  1338.      of columns [n] for the specified target lines.
  1339.  
  1340. COMPATIBILITY
  1341.      XEDIT: Compatible.
  1342.      KEDIT: Compatible.
  1343.  
  1344. STATUS
  1345.      Complete.
  1346. **man-end**********************************************************************/
  1347. #ifdef PROTO
  1348. short Shift(CHARTYPE *params)
  1349. #else
  1350. short Shift(params)
  1351. CHARTYPE *params;
  1352. #endif
  1353. /***********************************************************************/
  1354. {
  1355. /*--------------------------- local data ------------------------------*/
  1356. #define SHI_PARAMS  3
  1357.  CHARTYPE *word[SHI_PARAMS+1];
  1358.  short shift_left=(-1);
  1359.  LINETYPE num_lines=0L,true_line=0L;
  1360.  short num_cols=0,num_params=0;
  1361.  short rc=RC_OK;
  1362.  short target_type=TARGET_NORMAL|TARGET_BLOCK_CURRENT|TARGET_ALL;
  1363.  TARGET target;
  1364.  bool num_lines_based_on_scope=FALSE;
  1365. /*--------------------------- processing ------------------------------*/
  1366. #ifdef TRACE
  1367.  trace_function("comm4.c:   Shift");
  1368. #endif
  1369.  num_params = param_split(params,word,SHI_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1370.  if (num_params == 0)                                     /* no params */
  1371.    {
  1372.     display_error(3,(CHARTYPE *)"",FALSE);
  1373. #ifdef TRACE
  1374.     trace_return();
  1375. #endif
  1376.     return(RC_INVALID_OPERAND);
  1377.    }
  1378. /*---------------------------------------------------------------------*/
  1379. /* Validate first parameter:                                           */
  1380. /*    must be Left or Right                                            */
  1381. /*---------------------------------------------------------------------*/
  1382.  if (equal((CHARTYPE *)"left",word[0],1))
  1383.      shift_left = TRUE;
  1384.  if (equal((CHARTYPE *)"right",word[0],1))
  1385.      shift_left = FALSE;
  1386.  if (shift_left == (-1))
  1387.    {
  1388.     display_error(1,word[0],FALSE);
  1389. #ifdef TRACE
  1390.     trace_return();
  1391. #endif
  1392.     return(RC_INVALID_OPERAND);
  1393.    }
  1394. /*---------------------------------------------------------------------*/
  1395. /* Validate second parameter (if there is one)                         */
  1396. /*    If present, must be valid positive integer.                      */
  1397. /*    If not present, default to 1.                                    */
  1398. /*---------------------------------------------------------------------*/
  1399.  if (num_params < 2)
  1400.     num_cols = 1;
  1401.  else
  1402.    {
  1403.     if (!valid_positive_integer(word[1]))
  1404.       {
  1405.        display_error(4,word[1],FALSE);
  1406. #ifdef TRACE
  1407.        trace_return();
  1408. #endif
  1409.        return(RC_INVALID_OPERAND);
  1410.       }
  1411.     num_cols = atoi(word[1]);
  1412.    }
  1413. /*---------------------------------------------------------------------*/
  1414. /* Validate third  parameter (if there is one)                         */
  1415. /*    If present, must be valid target.                                */
  1416. /*    If not present, default to 1.                                    */
  1417. /*---------------------------------------------------------------------*/
  1418.  if (num_params < 3)                                      /* no target */
  1419.    {
  1420.     num_lines = 1L;
  1421.     true_line = get_true_line();
  1422.    }
  1423.  else
  1424.    {
  1425.     initialise_target(&target);
  1426.     if ((rc = validate_target(word[2],&target,target_type,get_true_line(),TRUE,TRUE)) != RC_OK)
  1427.       {
  1428.        free_target(&target);
  1429. #ifdef TRACE
  1430.        trace_return();
  1431. #endif
  1432.        return(rc);
  1433.       }
  1434.     num_lines = target.num_lines;
  1435.     true_line = target.true_line;
  1436.     num_lines_based_on_scope = (target.rt[0].target_type == TARGET_BLOCK_CURRENT) ? FALSE : TRUE;
  1437.     free_target(&target);
  1438.    }
  1439. /*---------------------------------------------------------------------*/
  1440. /* Now we are here, everything's OK, do the actual shift...            */
  1441. /*---------------------------------------------------------------------*/
  1442.  rc = execute_shift_command(shift_left,num_cols,true_line,num_lines,num_lines_based_on_scope);
  1443. #ifdef TRACE
  1444.  trace_return();
  1445. #endif
  1446.  return(rc);
  1447. }
  1448. /*man-start*********************************************************************
  1449. COMMAND
  1450.      showkey - display current key value and command assignation
  1451.  
  1452. SYNTAX
  1453.      SHOWKey 
  1454.  
  1455. DESCRIPTION
  1456.      The SHOWKEY command prompts the user to enter a key and responds
  1457.      with the key name and associated command (if applicable).
  1458.      To exit from SHOWKEY, press the space bar.
  1459.  
  1460. COMPATIBILITY
  1461.      XEDIT: N/A
  1462.      KEDIT: N/A
  1463.  
  1464. STATUS
  1465.      Complete.
  1466. **man-end**********************************************************************/
  1467. #ifdef PROTO
  1468. short ShowKey(CHARTYPE *params)
  1469. #else
  1470. short ShowKey(params)
  1471. CHARTYPE *params;
  1472. #endif
  1473. /***********************************************************************/
  1474. {
  1475. /*-------------------------- external data ----------------------------*/
  1476. /*--------------------------- local data ------------------------------*/
  1477.  int key=0;
  1478. /*--------------------------- processing ------------------------------*/
  1479. #ifdef TRACE
  1480.  trace_function("comm4.c:   ShowKey");
  1481. #endif
  1482. /*---------------------------------------------------------------------*/
  1483. /* No arguments are allowed; error if any are present.                 */
  1484. /*---------------------------------------------------------------------*/
  1485.  if (strcmp(params,"") != 0)
  1486.    {
  1487.     display_error(1,(CHARTYPE *)params,FALSE);
  1488. #ifdef TRACE
  1489.     trace_return();
  1490. #endif
  1491.     return(RC_INVALID_OPERAND);
  1492.    }
  1493.  display_prompt("Press the key to be translated...spacebar to exit");
  1494.  key = 0;
  1495.  while(key != ' ')
  1496.    {
  1497.     key = my_getch(stdscr);
  1498.     clear_msgline();
  1499.     display_prompt(get_key_definition(key));
  1500.    }
  1501.  clear_msgline();
  1502. #ifdef TRACE
  1503.  trace_return();
  1504. #endif
  1505.  return(RC_OK);
  1506. }
  1507. /*man-start*********************************************************************
  1508. COMMAND
  1509.      sort - sort selected lines in a file
  1510.  
  1511. SYNTAX
  1512.      SORT target [[[Ascending|Descending] left_col right_col] [...]]
  1513.  
  1514. DESCRIPTION
  1515.      The SORT command sort a portion of a file based on the sort field
  1516.      specifications.
  1517.      target can be any valid target including ALL, *, -*, and BLOCK.
  1518.      Each sort field specification consists of an optional ordering
  1519.      flag and a left and right column.
  1520.  
  1521.      Only 10 sort fields are allowed.
  1522.  
  1523. COMPATIBILITY
  1524.      XEDIT: XEDIT only allows ordering flag for all fields
  1525.      KEDIT: Compatible.
  1526.  
  1527. STATUS
  1528.      Complete.
  1529. **man-end**********************************************************************/
  1530. #ifdef PROTO
  1531. short Sort(CHARTYPE *params)
  1532. #else
  1533. short Sort(params)
  1534. CHARTYPE *params;
  1535. #endif
  1536. /***********************************************************************/
  1537. {
  1538. /*-------------------------- external data ----------------------------*/
  1539. /*--------------------------- local data ------------------------------*/
  1540.  short rc=RC_OK;
  1541. /*--------------------------- processing ------------------------------*/
  1542. #ifdef TRACE
  1543.  trace_function("comm4.c:   Sort");
  1544. #endif
  1545.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  1546.  rc = execute_sort(params);
  1547.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  1548.  build_current_screen(); 
  1549.  display_current_screen();
  1550. #ifdef TRACE
  1551.  trace_return();
  1552. #endif
  1553.  return(rc);
  1554. }
  1555. /*man-start*********************************************************************
  1556. COMMAND
  1557.      sos - execute various sos commands
  1558.  
  1559. SYNTAX
  1560.      SOS sos_command [sos_command ...]
  1561.  
  1562. DESCRIPTION
  1563.      The SOS command is a front end to existing 'sos' commands. It treats
  1564.      each parameter it receives as a command and executes it.
  1565.  
  1566. COMPATIBILITY
  1567.      XEDIT: XEDIT only permits 1 command
  1568.      KEDIT: Compatible.
  1569.  
  1570. STATUS
  1571.      Complete.
  1572. **man-end**********************************************************************/
  1573. #ifdef PROTO
  1574. short Sos(CHARTYPE *params)
  1575. #else
  1576. short Sos(params)
  1577. CHARTYPE *params;
  1578. #endif
  1579. /***********************************************************************/
  1580. {
  1581. /*--------------------------- local data ------------------------------*/
  1582.  register short i;
  1583. #define SOS_PARAMS  10
  1584.  CHARTYPE *word[SOS_PARAMS+1];
  1585.  short num_params=0;
  1586.  short rc=RC_OK;
  1587. /*--------------------------- processing ------------------------------*/
  1588. #ifdef TRACE
  1589.  trace_function("comm4.c:   Sos");
  1590. #endif
  1591.  num_params = param_split(params,word,SOS_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1592.  if (num_params == 0)                                     /* no params */
  1593.    {
  1594.     display_error(3,(CHARTYPE *)"",FALSE);
  1595. #ifdef TRACE
  1596.     trace_return();
  1597. #endif
  1598.     return(RC_INVALID_OPERAND);
  1599.    }
  1600. /*---------------------------------------------------------------------*/
  1601. /* For each "command" go an execute it.                                */
  1602. /*---------------------------------------------------------------------*/
  1603.  for (i=0;i<num_params;i++)
  1604.    {
  1605.     if ((rc = execute_set_sos_command(FALSE,word[i])) != RC_OK)
  1606.        break;
  1607.    }
  1608. #ifdef TRACE
  1609.  trace_return();
  1610. #endif
  1611.  return(rc);
  1612. }
  1613. /*man-start*********************************************************************
  1614. COMMAND
  1615.      split - split a line into two lines
  1616.  
  1617. SYNTAX
  1618.      SPlit [ALigned]
  1619.  
  1620. DESCRIPTION
  1621.      The SPLIT command splits the focus line into two lines.
  1622.      If ALIGNED is specified, the first non-blank character of the new
  1623.      line is positioned under the first non-blank character of the
  1624.      focus line. If ALIGNED is not specified, the text of the new line
  1625.      starts in column 1.
  1626.  
  1627. COMPATIBILITY
  1628.      XEDIT: Compatible.
  1629.      KEDIT: Compatible.
  1630.  
  1631. SEE ALSO
  1632.      JOIN, SPLTJOIN
  1633.  
  1634. STATUS
  1635.      Complete.
  1636. **man-end**********************************************************************/
  1637. #ifdef PROTO
  1638. short Split(CHARTYPE *params)
  1639. #else
  1640. short Split(params)
  1641. CHARTYPE *params;
  1642. #endif
  1643. /***********************************************************************/
  1644. {
  1645. /*-------------------------- external data ----------------------------*/
  1646.  extern bool curses_started;
  1647. /*--------------------------- local data ------------------------------*/
  1648.  unsigned short x=0,y=0,col=0;
  1649.  short rc=RC_OK;
  1650.  bool aligned=FALSE;
  1651. /*--------------------------- processing ------------------------------*/
  1652. #ifdef TRACE
  1653.  trace_function("comm4.c:   Split");
  1654. #endif
  1655. /*---------------------------------------------------------------------*/
  1656. /* Check here for parameter value of 'Aligned'.                        */
  1657. /*---------------------------------------------------------------------*/
  1658.  if (equal((CHARTYPE *)"aligned",params,2))
  1659.     aligned = TRUE;
  1660.  else
  1661.     if (strcmp(params,"") == 0)
  1662.        aligned = FALSE;
  1663.     else
  1664.       {
  1665.        display_error(1,(CHARTYPE *)params,FALSE);
  1666. #ifdef TRACE
  1667.        trace_return();
  1668. #endif
  1669.        return(RC_INVALID_ENVIRON);
  1670.       }
  1671.  if (curses_started)
  1672.    {
  1673.     getyx(CURRENT_WINDOW,y,x);
  1674.     col = (x+CURRENT_VIEW->verify_col-1);
  1675.    }
  1676.  else
  1677.     col = 0;
  1678.  rc = execute_split_join(TRUE,aligned,col);
  1679. #ifdef TRACE
  1680.  trace_return();
  1681. #endif
  1682.  return(rc);
  1683. }
  1684. /*man-start*********************************************************************
  1685. COMMAND
  1686.      spltjoin - split/join two lines
  1687.  
  1688. SYNTAX
  1689.      spltjoin
  1690.  
  1691. DESCRIPTION
  1692.      The SPLTJOIN command splits the focus line into two or joins the
  1693.      focus line with the next line depending on the position of the
  1694.      cursor. If the cursor is after the last column of a line, the JOIN
  1695.      command is executed, otherwise the SPLIT command is executed.
  1696.      The text in the new line is aligned with the text in the focus line.
  1697.  
  1698.      This command can only be used by assigning it to a function key.
  1699.  
  1700. COMPATIBILITY
  1701.      XEDIT: Compatible.
  1702.      KEDIT: Compatible.
  1703.  
  1704. SEE ALSO
  1705.      JOIN, SPLIT
  1706.  
  1707. STATUS
  1708.      Complete.
  1709. **man-end**********************************************************************/
  1710. #ifdef PROTO
  1711. short Spltjoin(CHARTYPE *params)
  1712. #else
  1713. short Spltjoin(params)
  1714. CHARTYPE *params;
  1715. #endif
  1716. /***********************************************************************/
  1717. {
  1718. /*-------------------------- external data ----------------------------*/
  1719.  extern bool curses_started;
  1720.  extern LENGTHTYPE rec_len;
  1721. /*--------------------------- local data ------------------------------*/
  1722.  unsigned short x=0,y=0,col=0;
  1723.  short rc=RC_OK;
  1724.  bool split=FALSE;
  1725. /*--------------------------- processing ------------------------------*/
  1726. #ifdef TRACE
  1727.  trace_function("comm4.c:   Spltjoin");
  1728. #endif
  1729.  if (curses_started)
  1730.    {
  1731.     getyx(CURRENT_WINDOW,y,x);
  1732.     col = (x+CURRENT_VIEW->verify_col-1);
  1733.    }
  1734.  else
  1735.     col = 0;
  1736. /*---------------------------------------------------------------------*/
  1737. /* Determine whether a split or join is to be performed.               */
  1738. /* If after end of line, join, else split the line.                    */
  1739. /*---------------------------------------------------------------------*/
  1740.  split = (col >= rec_len) ? FALSE : TRUE;
  1741.  rc = execute_split_join(split,TRUE,col);
  1742. #ifdef TRACE
  1743.  trace_return();
  1744. #endif
  1745.  return(rc);
  1746. }
  1747. /*man-start*********************************************************************
  1748. COMMAND
  1749.      ssave - force SAVE to specified file
  1750.  
  1751. SYNTAX
  1752.      SSave [fileid]
  1753.  
  1754. DESCRIPTION
  1755.      The SSAVE command writes the current file to disk. If a fileid is
  1756.      supplied, the current file is saved in that file, otherwise the
  1757.      current name of the file is used.
  1758.      If a fileid is supplied and that fileid already exists, the previous
  1759.      contents of that fileid will be replaced with the current file.
  1760.      The 'Alterations' counter on the heading line is reset to zero.
  1761.  
  1762. COMPATIBILITY
  1763.      XEDIT: N/A
  1764.      KEDIT: Compatible.
  1765.  
  1766. SEE ALSO
  1767.      SAVE, FILE, FFILE
  1768.  
  1769. STATUS
  1770.      Complete
  1771. **man-end**********************************************************************/
  1772. #ifdef PROTO
  1773. short Ssave(CHARTYPE *params)
  1774. #else
  1775. short Ssave(params)
  1776. CHARTYPE *params;
  1777. #endif
  1778. /***********************************************************************/
  1779. {
  1780. /*-------------------------- external data ----------------------------*/
  1781. /*--------------------------- local data ------------------------------*/
  1782.  short rc=RC_OK;
  1783. /*--------------------------- processing ------------------------------*/
  1784. #ifdef TRACE
  1785.  trace_function("comm4.c:   Ssave");
  1786. #endif
  1787.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line);
  1788.  if ((rc = save_file(CURRENT_FILE,params,TRUE,CURRENT_FILE->number_lines,1L,FALSE,0,max_line_length,TRUE)) != RC_OK)
  1789.    {
  1790. #ifdef TRACE
  1791.     trace_return();
  1792. #endif
  1793.     return(rc);
  1794.    }
  1795. /*---------------------------------------------------------------------*/
  1796. /* Only set the alteration count to zero if save was successful.       */
  1797. /*---------------------------------------------------------------------*/
  1798.  CURRENT_FILE->autosave_alt = CURRENT_FILE->save_alt = 0;
  1799. /*---------------------------------------------------------------------*/
  1800. /* If autosave is on at the time of SSaving, remove the .aus file...   */
  1801. /*---------------------------------------------------------------------*/
  1802.  if (CURRENT_FILE->autosave > 0)
  1803.     rc = remove_aus_file(CURRENT_FILE);
  1804. #ifdef TRACE
  1805.  trace_return();
  1806. #endif
  1807.  return(rc);
  1808. }
  1809. /*man-start*********************************************************************
  1810. COMMAND
  1811.      status - display current settings of various variables
  1812.  
  1813. SYNTAX
  1814.      STATus [filename]
  1815.  
  1816. DESCRIPTION
  1817.      The STATUS command, without the optional filename, displays a full
  1818.      screen of current settings for various variables. With the filename,
  1819.      the STATUS command creates a file containing a series of SET commands
  1820.      with the current values of these settings.
  1821.  
  1822. COMPATIBILITY
  1823.      XEDIT: Compatible.
  1824.      KEDIT: Compatible. KEDIT does not support [filename] option.
  1825.  
  1826. SEE ALSO
  1827.      QUERY, EXTRACT, MODIFY
  1828.  
  1829. STATUS
  1830.      Complete
  1831. **man-end**********************************************************************/
  1832. #ifdef PROTO
  1833. short Status(CHARTYPE *params)
  1834. #else
  1835. short Status(params)
  1836. CHARTYPE *params;
  1837. #endif
  1838. /***********************************************************************/
  1839. {
  1840. /*-------------------------- external data ----------------------------*/
  1841.  extern bool in_profile;
  1842.  extern bool in_macro;
  1843. /*--------------------------- local data ------------------------------*/
  1844.  short rc=RC_OK;
  1845. /*--------------------------- processing ------------------------------*/
  1846. #ifdef TRACE
  1847.  trace_function("comm4.c:   Status");
  1848. #endif
  1849.  if (strcmp(params,"") == 0)
  1850.    {
  1851.     if (in_profile || in_macro)
  1852.       {
  1853.        display_error(24,(CHARTYPE *)"status",FALSE);
  1854.        rc = RC_INVALID_ENVIRON;
  1855.       }
  1856.     else
  1857.        rc = show_status();
  1858.    }
  1859.  else
  1860.     rc = save_status(params);
  1861. #ifdef TRACE
  1862.  trace_return();
  1863. #endif
  1864.  return(rc);
  1865. }
  1866. /*man-start*********************************************************************
  1867. COMMAND
  1868.      suspend - suspend THE and return to operating system
  1869.  
  1870. SYNTAX
  1871.      SUSPend
  1872.  
  1873. DESCRIPTION
  1874.      The SUSPEND command suspends the current editing session and 
  1875.      returns control to the operating system. Under DOS and OS/2 this
  1876.      is the equivalent of OSNowait. Under UNIX, the process gets placed
  1877.      in the background until it is brought to the foreground.
  1878.  
  1879. COMPATIBILITY
  1880.      XEDIT: N/A
  1881.      KEDIT: N/A
  1882.  
  1883. SEE ALSO
  1884.      OSNOWAIT
  1885.  
  1886. STATUS
  1887.      Complete
  1888. **man-end**********************************************************************/
  1889. #ifdef PROTO
  1890. short Suspend(CHARTYPE *params)
  1891. #else
  1892. short Suspend(params)
  1893. CHARTYPE *params;
  1894. #endif
  1895. /***********************************************************************/
  1896. {
  1897. /*--------------------------- local data ------------------------------*/
  1898.  short rc=RC_OK;
  1899. #ifdef UNIX
  1900.  void (*func)();
  1901. #endif
  1902. /*--------------------------- processing ------------------------------*/
  1903. #ifdef TRACE
  1904.  trace_function("comm4.c:   Suspend");
  1905. #endif
  1906.  if (strcmp(params,"") != 0)
  1907.    {
  1908.     display_error(2,params,FALSE);
  1909. #ifdef TRACE
  1910.     trace_return();
  1911. #endif
  1912.     return(RC_INVALID_OPERAND);
  1913.    }
  1914. #if defined(UNIX) && !defined(ATT) && !defined(M_XENIX)
  1915.  if (strcmp("/bin/sh",getenv("SHELL")) == 0)
  1916.    {
  1917.     display_error(40,(CHARTYPE *)"",FALSE);
  1918. #ifdef TRACE
  1919.     trace_return();
  1920. #endif
  1921.     return(RC_INVALID_OPERAND);
  1922.    }
  1923.  suspend_curses();
  1924.  func = signal(SIGTSTP,SIG_DFL);
  1925.  kill(0,SIGTSTP);
  1926.  signal(SIGTSTP,func);
  1927.  resume_curses();
  1928.  Redraw((CHARTYPE *)"");
  1929. #else
  1930.  rc = execute_os_command(params,FALSE,FALSE);
  1931. #endif
  1932. #ifdef TRACE
  1933.  trace_return();
  1934. #endif
  1935.  return(rc);
  1936. }
  1937.